var lastPage = "";
var lastTime = new Date( - 300);
var nocache = false;
function loadSpPage(types, order, page) {
    $("#sp_order > a").removeClass("on");
    $("#sp_order_" + order).addClass("on");
    $("#tag_video_container > .loading").remove();
    $('<div class="loading"></div>').prependTo("#tag_video_container");
    var startTime = new Date();
	
    $.ajax({url:ajaxurl, type:"POST",data:{action: types,specialt_id:spid,order:order,page:page},
        success: function(data) {
            var dur = new Date().getTime() - startTime.getTime();
            if (dur < 500) {
                setTimeout(function() {
                    $("#tag_video_container").html(data);
                },
                300 - dur <= 0 ? 10 : 300 - dur);
            } else {
                $("#tag_video_container").html(data);
            }
        }
    });
}
function loadBgmPage(page, season_id) {
    $("#season_selector li.on").removeClass("on");
    $("#season_selector li[season_id=" + (season_id !== undefined ? season_id: 0) + "]").addClass("on");
    var curPage = "/sppage/bangumi-" + spid + "-" + (season_id !== undefined ? season_id + "-": "") + page + ".html" + (nocache ? "?r=" + Math.random() : "");
    if (curPage == lastPage) return;
    nocache = false;
    lastPage = curPage;
    $("#bgm_video_container > .loading").remove();
    $('<div class="loading"></div>').prependTo("#bgm_video_container");
    var startTime = new Date();
    $.ajax(lastPage, {
        success: function(data) {
            var dur = new Date().getTime() - startTime.getTime();
            if (dur < 500) {
                setTimeout(function() {
                    $("#bgm_video_container").html(data);
                },
                300 - dur <= 0 ? 10 : 300 - dur);
            } else {
                $("#bgm_video_container").html(data);
            }
        }
    });
}
function loadSpecialPage(page) {
    var curPage = "/sppage/sp-" + spid + "\-" + page + ".html" + (nocache ? "?r=" + Math.random() : "");
    if (curPage == lastPage) return;
    nocache = false;
    lastPage = curPage;
    $("#sp_video_container > .loading").remove();
    $('<div class="loading"></div>').prependTo("#sp_video_container");
    var startTime = new Date();
    $.ajax(lastPage, {
        success: function(data) {
            var dur = new Date().getTime() - startTime.getTime();
            if (dur < 500) {
                setTimeout(function() {
                    $("#sp_video_container").html(data);
                },
                300 - dur <= 0 ? 10 : 300 - dur);
            } else {
                $("#sp_video_container").html(data);
            }
        }
    });
}
function showSpAdbtn() {
    $(".zt-i > .mr").empty();
    if (isSpAtt == "1") {
        $('<a class="g on">已关注<i onclick="unattentionSp(this,spid)">取消</i></a>').appendTo(".zt-i > .mr");
    } else {
        $('<a class="g" href="javascript:" onclick="attentionSp(this,spid)">加关注</a>').appendTo(".zt-i > .mr");
    }
    if (isSpFav == "1") {
        $('<a class="s on">已收藏<i onclick="unfavouriteSp(this,spid)">取消</i>').appendTo(".zt-i > .mr");
    } else {
        $('<a class="s" onclick="favouriteSp(this,spid)">收藏</a>').appendTo(".zt-i > .mr");
    }
}
function bindAdmin() {
    $("a.lcd.add").click(function() {
        var sf = this;
        var msgbox = new MessageBox().show(this, '确认添加此视频到推荐区?<br />推荐值:<input type="text" class="minput" value="1">', 'button',
        function(mobj) {
            addVideo(sf, 'ad', $(sf).attr('val'), msgbox.find('.minput').val(), mobj.position);
        });
    });
    $("a.lcd.transfer").click(function() {
        var sf = this;
        $("#season_transfer_container").dialog({
            title: "新番季度转移",
            buttons: [{
                text: "确定",
                click: function() {
                    var dialog = this;
                    $.ajax("/spadmin?spid=" + spid + "&action=transfer_season&aid=" + $(sf).attr('val') + "&target_season=" + $("select", dialog).val(), {
                        success: function(data) {
                            switch (parseInt(data)) {
                            case 0:
                                nocache = true;
                                $(dialog).dialog("destroy");
                                $(sf).parent().hide("slide", {
                                    direction: "left"
                                },
                                500);
                                setTimeout(function() {
                                    var sfp_container = $(sf).parent().parent();
                                    $(sf).parent().remove();
                                    if (sfp_container.find("li, div").length <= 1) {
                                        loadBgmPage(1, $("#season_selector li.on").attr("season_id"));
                                    }
                                },
                                1000);
                                break;
                            case - 2 : new MessageBox().show($(".ui-dialog .ui-button").get(0), '此项目不存在', 2000, 'warning');
                                break;
                            case - 3 : new MessageBox().show($(".ui-dialog .ui-button").get(0), '此季度不存在', 2000, 'warning');
                                break;
                            default:
                                new MessageBox().show($(".ui-dialog .ui-button").get(0), data, 2000, 'error');
                            }
                        },
                        error: function() {
                            new MessageBox().show($(".ui-dialog .ui-button").get(0), '提交失败，可能权限不足', 2000, 'error');
                        }
                    });
                }
            },
            {
                text: "取消",
                click: function() {
                    $(this).dialog("destroy");
                }
            }],
            modal: true
        });
        $(".ui-dialog .ui-button:eq(0)").focus();
    });
    $("a.lcd.position").click(function() {
        var sf = this;
        $("#season_position_container").dialog({
            title: "新番季度位置调整",
            buttons: [{
                text: "确定",
                click: function() {
                    var dialog = this;
                    $.ajax("/spadmin?spid=" + spid + "&action=update_position&aid=" + $(sf).attr('val') + "&position=" + $("#ip_position", dialog).val() + "&recommend=" + $("#ip_order", dialog).val(), {
                        success: function(data) {
                            switch (parseInt(data)) {
                            case 0:
                                nocache = true;
                                $(dialog).dialog("destroy");
                                if (sfp_container.find("li, div").length <= 1) {
                                    loadBgmPage(1, $("#season_selector li.on").attr("season_id"));
                                }
                                break;
                            case - 2 : new MessageBox().show($(".ui-dialog .ui-button").get(0), '此项目不存在', 2000, 'warning');
                                break;
                            default:
                                new MessageBox().show($(".ui-dialog .ui-button").get(0), data, 2000, 'error');
                            }
                        },
                        error: function() {
                            new MessageBox().show($(".ui-dialog .ui-button").get(0), '提交失败，可能权限不足', 2000, 'error');
                        }
                    });
                }
            },
            {
                text: "取消",
                click: function() {
                    $(this).dialog("destroy");
                }
            }],
            open: function(event, ui) {
                var dialog = this;
                $("#ip_order", dialog).val($(sf).attr("order"));
                $("#ip_position", dialog).val($(sf).attr("position"));
            },
            modal: true
        });
        $(".ui-dialog .ui-button:eq(0)").focus();
    });
    $("a.lcd.del").click(function() {
        var sf = this;
        var msgbox = new MessageBox().show(this, '确认删除此内容?', 'button',
        function(mobj) {
            $.ajax("/spadmin?spid=" + spid + "&action=del&type=" + $(sf).attr('type') + "&aid=" + $(sf).attr('val'), {
                success: function(data) {
                    switch (parseInt(data)) {
                    case 0:
                        new MessageBox({
                            Overlap:
                            true,
                            position: mobj.position
                        }).show(sf, '删除成功', 1000, 'ok');
                        nocache = true;
                        $(sf).parent().hide("slide", {
                            direction: "left"
                        },
                        500);
                        setTimeout(function() {
                            var sfp_container = $(sf).parent().parent();
                            var sftype = parseInt($(sf).attr('type'));
                            $(sf).parent().remove();
                            if (sfp_container.find("li, div").length <= 1) {
                                switch (sftype) {
                                case 0:
                                    loadSpPage('ad', curorder, 1);
                                    break;
                                case 1:
                                    loadBgmPage(1);
                                    break;
                                case 2:
                                    loadSpecialPage(1);
                                    break;
                                }
                            }
                        },
                        1000);
                        break;
                    case - 2 : new MessageBox({
                            Overlap: true,
                            position: mobj.position
                        }).show(sf, '此项目不存在', 2000, 'warning');
                        break;
                    default:
                        new MessageBox({
                            Overlap:
                            true,
                            position: mobj.position
                        }).show(sf, data, 2000, 'error');
                    }
                },
                error: function() {
                    new MessageBox({
                        Overlap: true,
                        position: mobj.position
                    }).show(sf, '提交失败，可能权限不足', 2000, 'error');
                }
            });
        });
    });
}
function bindBangumiElement(ele) {
    $(".ui-icon-close", ele).click(function() {
        var menu_item = this.parentNode;
        var season_id = $(menu_item).attr("season_id");
        var sf = this;
        var msgbox = new MessageBox().show(this, '确认删除此季度?', 'button',
        function(mobj) {
            $.ajax("/spadmin?spid=" + spid + "&action=del_season&season_id=" + season_id, {
                success: function(data) {
                    switch (parseInt(data)) {
                    case 0:
                        $(menu_item).hide("slide", {
                            direction: "left"
                        },
                        500,
                        function() {
                            $(menu_item).remove();
                        });
                        break;
                    case - 2 : new MessageBox({
                            Overlap: true,
                            position: mobj.position
                        }).show(sf, '此项目不存在', 2000, 'warning');
                        break;
                    default:
                        new MessageBox({
                            Overlap:
                            true,
                            position: mobj.position
                        }).show(sf, data, 2000, 'error');
                    }
                },
                error: function() {
                    new MessageBox({
                        Overlap: true,
                        position: mobj.position
                    }).show(sf, '提交失败，可能权限不足', 2000, 'error');
                }
            });
        });
        return false;
    });
    $(ele).click(function() {
        var season_id = $(this).attr("season_id");
        if (!season_id) {
            loadBgmPage(1);
        } else {
            if ($(this).attr("default") == "0") {
                $("#btn_set_season_default").show();
            } else {
                $("#btn_set_season_default").hide();
            }
            if ($(this).attr("counting") == "0") {
                $("#btn_set_season_count_default").show();
            } else {
                $("#btn_set_season_count_default").hide();
            }
            loadBgmPage(1, season_id);
        }
    });
}
function bindSpElement() {
    $("#sp_ad").click(function() {
        curtab = "ad";
        $("#zt_add").show();
        $("#sp_tag").removeClass("on");
        $("#sp_ad").addClass("on");
        $("#sp_order_recommend").show();
        loadSpPage(curtab, 'recommend', 1);
    });
    $("#sp_tag").click(function() {
        curtab = "tag";
        $("#zt_add").hide();
        $("#sp_ad").removeClass("on");
        $("#sp_tag").addClass("on");
        $("#sp_order_recommend").hide();
        loadSpPage(curtab, 'hot', 1);
    });
    $("#sp_order_recommend").click(function() {
        loadSpPage(curtab, 'recommend', 1);
        return false;
    });
    $("#sp_order_hot").click(function() {
        loadSpPage(curtab, 'hot', 1);
        return false;
    });
    $("#sp_order_new").click(function() {
        loadSpPage(curtab, 'new', 1);
        return false;
    });
    var ac = {
        source: function(request, response) {
            $.getJSON("/m/suggest?jsoncallback=?", {
                term: request.term.replace(/　/g, ""),
                rnd: Math.random()
            },
            response);
        },
        search: function() {
            var term = this.value;
            if (term.charCodeAt(0) < 255 && term.length < 2 || term.length > 10) {
                return false;
            }
        },
        focus: function() {
            return false;
        },
        select: function(event, ui) {
            this.value = ui.item.value;
            return false;
        }
    };
    if ($("#sp_tag_add").length > 0) {
        $("#sp_tag_add").attr("autocomplete", "off");
        $("#sp_tag_add").autocomplete(ac).data("autocomplete")._renderItem = function(ul, item) {
            return $("<li></li>").data("item.autocomplete", item).append("<a style=\"text-align:left\">" + item.value + "<em style=\"float:right;font-size:10px;\"" + (item.match ? " title=\"(Match Token: " + item.match + ")\"": "") + ">" + (item.desc ? item.desc: item.ref + "个") + "</em></a>").appendTo(ul);
        };
        $("#sp_tag_add_btn").click(function() {
            var obj = this;
            msgbox = new MessageBox();
            var kt = $("#sp_tag_add").val();
            $.ajax("/spadmin?action=addtag&spid=" + spid + "&tag=" + encodeURIComponent(kt), {
                success: function(data) {
                    if (data == "OK") {
                        $("#sp_tag_add").val("");
                        $("<i>" + kt + "</i>").appendTo(".tag");
                    }
                    msgbox.show(obj, data == 'OK' ? '添加成功!': data, data == 'OK' ? 500 : 2000, data == 'OK' ? 'ok': 'warning');
                },
                error: function() {
                    msgbox.show(obj, '系统错误，请稍后重试!', 2000, 'error');
                }
            });
        });
    }
    if (isSpAtt != "") {
        showSpAdbtn();
        if ($("#sptitle").length > 0) {
            var ac = {
                source: function(request, response) {
                    $.getJSON("/spadmin?action=suggest&spid=" + spid + "&jsoncallback=?", {
                        term: request.term.replace(/　/g, ""),
                        rnd: Math.random()
                    },
                    response);
                },
                search: function() {
                    var term = this.value;
                    if (term.charCodeAt(0) < 255 && term.length < 2 || term.length > 10) {
                        return false;
                    }
                },
                focus: function() {
                    return false;
                },
                select: function(event, ui) {
                    this.value = ui.item.value;
                    return false;
                }
            };
            $("#sptitle").attr("autocomplete", "off");
            $("#sptitle").autocomplete(ac).data("autocomplete")._renderItem = function(ul, item) {
                return $("<li></li>").data("item.autocomplete", item).append("<a style=\"text-align:left\">" + item.value + "</a>").appendTo(ul);
            };
            $("#fsp_name").attr("autocomplete", "off");
            $("#fsp_name").autocomplete(ac).data("autocomplete")._renderItem = function(ul, item) {
                return $("<li></li>").data("item.autocomplete", item).append("<a style=\"text-align:left\">" + item.value + "</a>").appendTo(ul);
            };
        }
    }
}
function addVideo(msgobj, type, aid, recommend, position) {
    $.ajax({url:ajaxurl,type:"POST",data:{action: 'add_video',specialt_id:spid,post_id:$("#sp_avid").val()},
        success: function(data) {
            switch (parseInt(data)) {
            case 0:
                new MessageBox({
                    Overlap:
                    true,
                    position: position
                }).show(msgobj, '添加成功', 1000, 'ok');
                if (typeof(position) == "undefined") {
                    setTimeout(function() {
                        nocache = true;
                        if (type == 'bangumi') {
                            loadBgmPage(1, $("#season_selector li.on").attr("season_id"));
                            $('#bgm_avid').val('');
                        } else {
                            loadSpPage(type, curorder, 1);
                            $('#sp_avid').val('');
                        }
                    },
                    1000);
                }
                break;
            case - 1 : new MessageBox({
                    Overlap: true,
                    position: position
                }).show(msgobj, '投稿不存在', 2000, 'warning');
                break;
            case - 2 : new MessageBox({
                    Overlap: true,
                    position: position
                }).show(msgobj, '此项目已存在', 2000, 'warning');
                break;
            default:
                new MessageBox({
                    Overlap:
                    true,
                    position: position
                }).show(msgobj, data, 2000, 'error');
            }
        },
        error: function() {
            new MessageBox({
                Overlap: true,
                position: position
            }).show(msgobj, '提交失败，可能权限不足', 2000, 'error');
        }
    });
    return false;
}
function addSpecial(msgobj, aid, recommend, position) {
    $.ajax("/spadmin?spid=" + spid + "&action=addsp&aid=" + aid + "&recommend=" + recommend, {
        success: function(data) {
            switch (parseInt(data)) {
            case 0:
                new MessageBox({
                    Overlap:
                    true,
                    position: position
                }).show(msgobj, '添加成功', 1000, 'ok');
                if (typeof(position) == "undefined") {
                    setTimeout(function() {
                        nocache = true;
                        loadSpecialPage(1);
                    },
                    1000);
                }
                break;
            case - 1 : new MessageBox({
                    Overlap: true,
                    position: position
                }).show(msgobj, '投稿不存在', 2000, 'warning');
                break;
            case - 2 : new MessageBox({
                    Overlap: true,
                    position: position
                }).show(msgobj, '此项目已存在', 2000, 'warning');
                break;
            case - 3 : new MessageBox({
                    Overlap: true,
                    position: position
                }).show(msgobj, '不能添加和自己一样的专题', 2000, 'warning');
                break;
            default:
                new MessageBox({
                    Overlap:
                    true,
                    position: position
                }).show(msgobj, data, 2000, 'error');
            }
        },
        error: function() {
            new MessageBox({
                Overlap: true,
                position: position
            }).show(msgobj, '提交失败，可能权限不足', 2000, 'error');
        }
    });
    return false;
}
function favouriteSp(obj, spid) {
    var msgbox = new MessageBox();
    $.ajax("/spadmin?action=favourite&spid=" + spid, {
        success: function(data) {
            msgbox.show(obj, data == 'OK' ? '收藏成功!': data, data == 'OK' ? 1000 : 2000, data == 'OK' ? 'ok': 'warning');
            if (data == "OK") {
                isSpFav = "1";
                showSpAdbtn();
            }
        },
        error: function() {
            msgbox.show(obj, '系统错误，请稍后重试!', 2000, 'error');
        }
    });
}
function unfavouriteSp(obj, spid) {
    var msgbox = new MessageBox();
    $.ajax("/spadmin?action=unfavourite&spid=" + spid, {
        success: function(data) {
            msgbox.show(obj, data == 'OK' ? '取消收藏成功!': data, data == 'OK' ? 1000 : 2000, data == 'OK' ? 'ok': 'warning');
            if (data == "OK") {
                isSpFav = "0";
                showSpAdbtn();
            }
        },
        error: function() {
            msgbox.show(obj, '系统错误，请稍后重试!', 2000, 'error');
        }
    });
}
function attentionSp(obj, spid) {
    var msgbox = new MessageBox();
    $.ajax("/spadmin?action=attention&spid=" + spid, {
        success: function(data) {
            msgbox.show(obj, data == 'OK' ? '关注成功!': data, data == 'OK' ? 1000 : 2000, data == 'OK' ? 'ok': 'warning');
            if (data == "OK") {
                isSpAtt = "1";
                showSpAdbtn();
            }
        },
        error: function() {
            msgbox.show(obj, '系统错误，请稍后重试!', 2000, 'error');
        }
    });
}
function unattentionSp(obj, spid) {
    var msgbox = new MessageBox();
    $.ajax("/spadmin?action=unattention&spid=" + spid, {
        success: function(data) {
            msgbox.show(obj, data == 'OK' ? '取消关注成功!': data, data == 'OK' ? 1000 : 2000, data == 'OK' ? 'ok': 'warning');
            if (data == "OK") {
                isSpAtt = "0";
                showSpAdbtn();
            }
        },
        error: function() {
            msgbox.show(obj, '系统错误，请稍后重试!', 2000, 'error');
        }
    });
}
function addFriend(msgobj, spid, title) {
    $.ajax("/spadmin?spid=" + spid + "&action=addfriend&aid=" + encodeURIComponent(title), {
        success: function(data) {
            switch (parseInt(data)) {
            case 0:
                new MessageBox({
                    Overlap:
                    true
                }).show(msgobj, '添加成功(刷新后可见)', 1000, 'ok');
                if (typeof(position) == "undefined") {
                    setTimeout(function() {
                        nocache = true;
                        loadSpecialPage(1);
                    },
                    1000);
                }
                break;
            case - 1 : new MessageBox({
                    Overlap: true
                }).show(msgobj, '投稿不存在', 2000, 'warning');
                break;
            case - 2 : new MessageBox({
                    Overlap: true
                }).show(msgobj, '此项目已存在', 2000, 'warning');
                break;
            case - 3 : new MessageBox({
                    Overlap: true
                }).show(msgobj, '不能添加和自己一样的专题', 2000, 'warning');
                break;
            default:
                new MessageBox({
                    Overlap:
                    true
                }).show(msgobj, data, 2000, 'error');
            }
        },
        error: function() {
            new MessageBox({
                Overlap: true,
                position: position
            }).show(msgobj, '提交失败，可能权限不足', 2000, 'error');
        }
    });
    return false;
}
function delFriend(sf, spid, dspid) {
    var msgbox = new MessageBox().show(sf, '确认删除此专题?', 'button',
    function(mobj) {
        $.ajax("/spadmin?spid=" + spid + "&action=delfdsp&dspid=" + dspid, {
            success: function(data) {
                switch (parseInt(data)) {
                case 0:
                    new MessageBox({
                        Overlap:
                        true,
                        position: mobj.position
                    }).show(sf, '删除成功', 1000, 'ok');
                    $(sf).parent().parent().slideUp(200);
                    break;
                case - 2 : new MessageBox({
                        Overlap: true,
                        position: mobj.position
                    }).show(sf, '此项目不存在', 2000, 'warning');
                    break;
                default:
                    new MessageBox({
                        Overlap:
                        true,
                        position: mobj.position
                    }).show(sf, data, 2000, 'error');
                }
            },
            error: function() {
                new MessageBox({
                    Overlap: true,
                    position: mobj.position
                }).show(sf, '提交失败，可能权限不足', 2000, 'error');
            }
        });
    });
}
function delTag() {
    var self = this;
    tag = $(self).attr('tag'); (new MessageBox()).show(self, '确认删除关键字?', 'button',
    function() {
        $.ajax("/spadmin?action=deltag&spid=" + spid + "&tag=" + encodeURIComponent(tag), {
            success: function(data) { (new MessageBox()).show(self, data == "OK" ? "删除成功": data, data == "OK" ? 500 : 2000, data == "OK" ? "info": "warning");
                if (data == "OK") $(self).parent().fadeOut(200);
            },
            error: function() { (new MessageBox()).show(self, "删除失败，请检查您的网络", 2000, "error");
            }
        });
    });
}
var bbs_lastfpage = 1;
var bbs_lastpage = 1;
var bbs_lasttid = 0;
var bbs_lastact = "";
var bbs_inaction = false;
var bbs_inaction_timer;
function loadBBS(spid, page, params) {
    bbs_lastact = "bbs";
    bbs_lastfpage = page;
    $("#zt_c_bbs > .loading").remove();
    $('<div class="loading"></div>').prependTo("#zt_c_bbs");
    var startTime = new Date();
    window.location.hash = "#f" + page;
    $.ajax("/spbbs/f" + spid + "-" + page + ".html" + (params !== undefined ? "?" + params: ""), {
        success: function(data) {
            var dur = new Date().getTime() - startTime.getTime();
            if (dur < 500) {
                setTimeout(function() {
                    $("#zt_c_bbs").html(data);
                    bindCardEvent("#zt_c_bbs");
                },
                300 - dur <= 0 ? 10 : 300 - dur);
            } else {
                $("#zt_c_bbs").html(data);
                bindCardEvent("#zt_c_bbs");
            }
        }
    });
}
function loadBBSThread(tid, page, fpage, params) {
    bbs_lastact = "thread";
    bbs_lastpage = page;
    bbs_lastfpage = fpage;
    bbs_lasttid = tid;
    $("#zt_c_bbs > .loading").remove();
    $('<div class="loading"></div>').prependTo("#zt_c_bbs");
    var startTime = new Date();
    window.location.hash = "#t" + tid + "-" + page + "-" + fpage;
    $.ajax("/spbbs/t" + tid + "-" + page + "-" + fpage + ".html" + (params !== undefined ? "?" + params: ""), {
        success: function(data) {
            var dur = new Date().getTime() - startTime.getTime();
            if (dur < 500) {
                setTimeout(function() {
                    $("#zt_c_bbs").html(data);
                    bindCardEvent("#zt_c_bbs");
                },
                300 - dur <= 0 ? 10 : 300 - dur);
            } else {
                $("#zt_c_bbs").html(data);
                bindCardEvent("#zt_c_bbs");
            }
        }
    });
}
function bbsManager_start() {
    bbs_inaction = true;
    var bbs_inaction_timer = setTimeout(function() {
        bbs_inaction = false;
    },
    5000);
}
function bbsManager_end() {
    clearTimeout(bbs_inaction_timer);
    bbs_inaction = false;
    $("body").css("cursor", "default");
}
function bbsManage_del(obj, rootObj, spid, action, tid) {
    var self = obj;
    bbsManager_start(); (new MessageBox()).show(obj, '确认' + (action == "del_thread" ? "删除": "恢复") + '此贴子?', 'button',
    function() {
        $("body").css("cursor", "progress");
        $.ajax("/spbbs/manage?action=" + action + "&spid=" + spid + "&tid=" + tid, {
            success: function(data) { (new MessageBox()).show(self, data == "OK" ? "删除成功": data, data == "OK" ? 500 : 2000, data == "OK" ? "info": "warning");
                if (data == "OK") {
                    if (action == "del_thread") {
                        $(rootObj).remove();
                    } else {
                        if (bbs_lastact == "bbs") {
                            loadBBS(spid, bbs_lastfpage);
                        } else {
                            loadBBSThread(bbs_lasttid, bbs_lastpage, bbs_lastfpage);
                        }
                    }
                }
                bbsManager_end();
            },
            error: function() { (new MessageBox()).show(self, "删除失败，请检查您的网络", 2000, "error");
                bbsManager_end();
            }
        });
    });
}
function bbsManage_setprops(obj, rootObj, spid, opt_msg, action, tid) {
    var self = obj;
    bbsManager_start(); (new MessageBox()).show(obj, '确认' + opt_msg + '此贴子?', 'button',
    function() {
        $("body").css("cursor", "progress");
        $.ajax("/spbbs/manage?action=" + action + "&spid=" + spid + "&tid=" + tid, {
            success: function(data) { (new MessageBox()).show(self, data == "OK" ? opt_msg + "成功": data, data == "OK" ? 500 : 2000, data == "OK" ? "info": "warning");
                if (bbs_lastact == "bbs") {
                    loadBBS(spid, bbs_lastfpage);
                } else {
                    loadBBSThread(bbs_lasttid, bbs_lastpage, bbs_lastfpage);
                }
                bbsManager_end();
            },
            error: function() { (new MessageBox()).show(self, opt_msg + "失败，请检查您的网络及权限", 2000, "error");
                bbsManager_end();
            }
        });
    });
}
function bbsManage_delPost(obj, action, tid, pid) {
    var self = obj;
    bbsManager_start(); (new MessageBox()).show(obj, '确认' + (action == "del_post" ? "删除": "恢复") + '此贴子?', 'button',
    function() {
        $("body").css("cursor", "progress");
        $.ajax("/spbbs/manage?action=" + action + "&spid=" + spid + "&tid=" + tid + "&pid=" + pid, {
            success: function(data) { (new MessageBox()).show(self, data == "OK" ? "删除成功": data, data == "OK" ? 500 : 2000, data == "OK" ? "info": "warning");
                if (data == "OK") {
                    if (action == "del_post") {
                        $("#pid-" + pid).slideUp(200,
                        function() {
                            $("#pid-" + pid).remove();
                        });
                    } else {
                        loadBBSThread(bbs_lasttid, bbs_lastpage, bbs_lastfpage);
                    }
                }
                bbsManager_end();
            },
            error: function() { (new MessageBox()).show(self, "删除失败，请检查您的网络", 2000, "error");
                bbsManager_end();
            }
        });
    });
}
$(function() {
    $("#add_spadmin_ok").click(function() {
        $("#add_admin_btn").hide();
        $('#add_admin_bk_info').html("已发送申请");
        $('#add_admin_bk_info').show();
        $('.float_window').hide();
    });
    $("#add_admin_btn").click(function() {
        $('#float_window').html($('#app_admin_none').html());
        $('.float_window').css({
            left: $(this).offset().left - 230,
            top: $(this).offset().top - 17
        });
        $('.float_window').show();
    });
});